using MediatR;
using Microsoft.AspNetCore.Mvc;
using RBAC.ErrorCode;
using SmartHealthcare.Write.Api.Application.Command.HospitalExpense;
using System.Threading.Tasks;

namespace SmartHealthcare.Write.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class HospitalExpenseController : ControllerBase
    {
        private readonly IMediator _mediator;
        private readonly ILogger<HospitalExpenseController> _logger;

        public HospitalExpenseController(IMediator mediator, ILogger<HospitalExpenseController> logger)
        {
            _mediator = mediator;
            _logger = logger;
        }

        /// <summary>
        /// 创建住院费用记录
        /// </summary>
        /// <param name="command">创建住院费用记录命令</param>
        /// <returns>新创建的记录ID</returns>
        [HttpPost]
        public async Task<APIResult<long>> CreateHospitalExpense([FromBody] CreateHospitalExpenseCommand command)
        {
            _logger.LogInformation($"接收到创建住院费用记录请求，患者：{command.PatientName}，项目：{command.ItemName}");
            return await _mediator.Send(command);
        }

        /// <summary>
        /// 推送住院费用通知
        /// </summary>
        /// <param name="command">推送住院费用通知命令</param>
        /// <returns>推送结果</returns>
        [HttpPost]
        public async Task<APIResult<bool>> PushExpenseNotification([FromBody] PushExpenseNotificationCommand command)
        {
            _logger.LogInformation($"接收到推送住院费用通知请求，费用ID：{command.ExpenseId}，病人卡号：{command.MedicalCard}，住院登记ID：{command.InpatientRegistryId}");
            return await _mediator.Send(command);
        }
    }
} 